package com.miracle.test;

import java.util.ArrayList;
import java.util.List;

public class ListLength {

    public static void main(String[] args) {
        list();
    }

    public static void list(){
        int length  = (int) Math.pow(10, 8);
        List<Integer> list = new ArrayList(length);
        for (int i = 0; i < length; i++) {
            list.add(i, new Integer(i));
        }




        long cout = 0;
        for (int v = 0; v < 20; v++) {
            long l3 = System.currentTimeMillis();
            int len = list.size();
            for (int i = 0; i < len; i++) {
                list.set(i, new Integer(i+10));
            }

            long l4 = System.currentTimeMillis();
            cout += l4-l3;
            System.out.println("T2:"+(l4-l3));
        }
        List a = new ArrayList();
        a.isEmpty();
        System.out.println("count:"+cout + "avg:"+ cout/20);


        //----------------------------------------------------------
        //long cout = 0;
        //for (int v = 0; v < 20; v++) {
        //    long l3 = System.currentTimeMillis();
        //    for (int i = 0; i < list.size(); i++) {
        //        list.set(i, new Integer(i+10));
        //    }
        //
        //    long l4 = System.currentTimeMillis();
        //    cout += l4-l3;
        //    System.out.println("T2:"+(l4-l3));
        //}
        //System.out.println("count:"+cout + "avg:"+ cout/20);
    }
}
